//
// Created by zerax on 2020/11/1.
//

#include "frame.hh"
#include <glad/glad.h>

Frame::Frame() {
    glGenFramebuffers(1, &m_framebuffer);
    glGenTextures(1, &m_bufferTexture);
}

Frame::~Frame() {
    if (m_framebuffer) glDeleteFramebuffers(1, &m_framebuffer);
}

Frame &Frame::operator=(Frame && other) noexcept {
    m_framebuffer = other.m_framebuffer;
    other.m_framebuffer = 0;
    return *this;
}



void Frame::draw() {
    glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);

    update();

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
